package com.demo.model;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
public class Users {

    // 方法获取User对象（Spring中存储的是返回的对象）
    // 方法注解

    @Bean
    public User userZ() {
        User user = new User();
        user.setId(1);
        user.setName("小周");
        user.setAge(20);
        return user;
    }

    @Bean
    public User userY() {
        User user = new User();
        user.setId(2);
        user.setName("耶耶");
        user.setAge(18);
        return user;
    }

    @Bean(name = "userKe")
    // @Scope("prototype") // 设置 原型模式！
    // @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public User userK() {
        User user = new User();
        user.setId(3);
        user.setName("keke");
        user.setAge(16);
        return user;
    }
}
